package com.biz.primus.model.coupon.vo.coupon.request;

import com.biz.primus.base.exception.utils.AssertUtils;
import com.biz.primus.model.coupon.exceptions.CouponExceptionType;
import com.biz.primus.model.coupon.interfaces.IModelValidation;
import com.biz.primus.model.coupon.vo.coupon.GetOrderProductAvailableCouponProductItemVo;
import com.google.common.collect.Lists;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
import java.util.List;
import java.util.Optional;
import lombok.Getter;
import lombok.Setter;

/**
 * 获取优惠券减免订单金额请求Vo
 *
 * @author david-liu
 */
@ApiModel(value = "获取优惠券减免订单金额请求Vo")
@Getter
@Setter
public class GetCouponCutAmountReqVo implements Serializable, IModelValidation {
    private static final long serialVersionUID = -6686999322820310070L;

    @ApiModelProperty(value = "用户ID")
    private Long userId;

    @ApiModelProperty(value = "优惠券ID")
    private Long couponId;

    @ApiModelProperty(value = "计算优惠券减免订单商品金额商品项")
    private List<GetOrderProductAvailableCouponProductItemVo> items;

    @Override
    public void validate() {
        AssertUtils.notNull(userId, CouponExceptionType.COUPON_USER_NOT_ALLOW_NULL);
        AssertUtils.notNull(couponId, CouponExceptionType.COUPON_ID_NOT_ALLOW_NULL);
        Optional.ofNullable(items).orElse(Lists.newArrayList()).forEach(GetOrderProductAvailableCouponProductItemVo::validate);
    }
}
